<template>
  <div class="match-status-badge" @click="handleClick">
    <el-tag 
      :type="statusType" 
      size="small" 
      :effect="statusEffect"
    >
      {{ statusText }}
    </el-tag>
    <div v-if="order" class="order-info">
      <el-icon><Connection /></el-icon>
      {{ order.orderId }}
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { Connection } from '@element-plus/icons-vue'

interface Props {
  status: string
  order?: any
}

const props = withDefaults(defineProps<Props>(), {
  status: 'unmatched',
  order: undefined
})

const emit = defineEmits<{
  (e: 'click-match'): void
}>()

const statusType = computed(() => {
  const typeMap: Record<string, string> = {
    'matched': 'success',
    'pending': 'warning',
    'unmatched': 'info'
  }
  return typeMap[props.status] || 'info'
})

const statusEffect = computed(() => {
  return props.status === 'matched' ? 'dark' : 'light'
})

const statusText = computed(() => {
  const textMap: Record<string, string> = {
    'matched': '已匹配',
    'pending': '待确认',
    'unmatched': '未匹配'
  }
  return textMap[props.status] || '未知状态'
})

const handleClick = () => {
  emit('click-match')
}
</script>

<style scoped lang="scss">
.match-status-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  cursor: pointer;
  
  .order-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #909399;
    
    .el-icon {
      font-size: 12px;
    }
  }
}
</style>